package com.hujf.netty.nio.zerocopy;

import java.io.BufferedReader;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.nio.ByteBuffer;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;

/**
 * @author Hujf
 * @title: NewIOServer
 * @date 2021/1/26 0026下午 4:51
 * @description: TODO
 */
public class NewIOServer {
    public static void main(String[] args) throws IOException {
        ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
        ServerSocket serverSocket = serverSocketChannel.socket();
        serverSocket.bind(new InetSocketAddress(7001));

        ByteBuffer byteBuffer = ByteBuffer.allocate(4096);

        while(true){
            SocketChannel socketChannel = serverSocketChannel.accept();
            int len =0;
            while(-1!=len){
                len =socketChannel.read(byteBuffer);
                //
                byteBuffer.rewind();
            }

        }

    }
}
